﻿using UnityEngine;
/// <summary>
/// Battle Radius Component for Enemies
/// </summary>
class BattleRadius : MonoBehaviour
{
    /// <summary>
    /// When a object that is tagged player collides with the Battle Radius a battle is engaged and enemy marks the player as a Target
    /// </summary>
    /// <param name="collision"></param>
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            gameObject.transform.parent.GetComponent<EnemyView>().enemyEntity.isBattleEngaged = true;
            gameObject.transform.parent.GetComponent<EnemyView>().enemyEntity.AddTargetInformation(collision.GetComponent<PlayerView>()
                .Player.name.value,collision.GetComponent<PlayerView>().Player.contextInfo.name);
        }
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
       
        if (collision.tag == "Player")
        {
            gameObject.transform.parent.GetComponent<EnemyView>().enemyEntity.isBattleEngaged = false;
           gameObject.transform.parent.GetComponent<EnemyView>().enemyEntity.RemoveTargetInformation();
        }



    }
}

